package com.example.parion;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.SmsMessage;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;

public class MyReceiver extends BroadcastReceiver {

	private static final String TAG = null;
	
	String outcomingNumber;
	@Override
	public void onReceive(Context context, Intent intent) {
	    // TODO Auto-generated method stub
		Log.d("SMS","111111111111111111111111" );
		if(intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL))
		{
			outcomingNumber=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
			Log.d("Phone","IDLE ;; number : " + outcomingNumber );
			
		}

		
		
		
		
		MyPhoneStateListener phoneListener = new MyPhoneStateListener(intent);
		 TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
		 telephony.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
		 Intent testActivityIntent = new Intent(context,MainActivity.class);
		 testActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		testActivityIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
		
		
		
//		context.startActivity(testActivityIntent);

	}
	
	
	
	

}

